//
//  ClassificationViewController.m
//  MarryMe
//
//  Created by lanou3g on 16/1/9.
//  Copyright © 2016年 revocher. All rights reserved.
//

#import "ClassificationViewController.h"
#import "FuwuTableViewCell.h"
#import "PhotoTableViewCell.h"
#import "CaigouTableViewCell.h"
#import "ReimenTableViewCell.h"
#import "ShangjiaViewController.h"
#import "LabelViewController.h"
#import "AllLabelViewController.h"
@interface ClassificationViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UITableView *mainTableView;

@property(nonatomic,strong)NSString *cityId;
@end

@implementation ClassificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSLog(@"为什么");
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(setcity:) name:@"city" object:nil];

    
    //监听通知
    //婚礼服务
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(huaizhuang:) name:@"huazhuang" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(sheying:) name:@"sheying" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(shexiang:) name:@"shexiang" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(zhuchi:) name:@"zhuchi" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(lifu:) name:@"lifu" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hunlisheying:) name:@"hunlisheying" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cehuai:) name:@"cehuai" object:nil];
    
    //热门标签
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image1:) name:@"image1" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image2:) name:@"image2" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image3:) name:@"image3" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image4:) name:@"image4" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image5:) name:@"image5" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image6:) name:@"image6" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image7:) name:@"image7" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image8:) name:@"image8" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(image9:) name:@"image9" object:nil]; 
    
    
    self.mainTableView.delegate = self;
    self.mainTableView.dataSource = self;
    
    //cell如果是xib文件,使用以下方式去注册
    [self.mainTableView registerNib:[UINib nibWithNibName:@"FuwuTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FuwuTableViewCell"];
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"CaigouTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CaigouTableViewCell"];
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"ReimenTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"ReimenTableViewCell"];
    
    [self.mainTableView registerNib:[UINib nibWithNibName:@"PhotoTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"PhotoTableViewCell"];
    
    NSLog(@"&&&&&&%@",self.cityId);
}

-(void)setcity:(NSNotification *)sender{
    self.cityId = sender.userInfo[@"cityName"];
    NSLog(@"********%@",sender.userInfo);
}

-(void)huaizhuang:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"9";
    shangjiaVC.cityId = self.cityId;
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)zhuchi:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"11";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)sheying:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"7";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)shexiang:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"8";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)lifu:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"12";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)hunlisheying:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"6";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)cehuai:(NSNotification *)sender{
    ShangjiaViewController *shangjiaVC = [[ShangjiaViewController alloc]init];
    shangjiaVC.property = @"2";
    [self.navigationController pushViewController:shangjiaVC animated:YES];
}

-(void)image1:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"42";
    labelVC.label = sender.userInfo[@"中式婚礼"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image2:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"73";
    labelVC.label = sender.userInfo[@"森系婚礼"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image3:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"36";
    labelVC.label = sender.userInfo[@"双机位"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image4:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"64";
    labelVC.label = sender.userInfo[@"花海婚纱"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image5:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"76";
    labelVC.label = sender.userInfo[@"水下婚纱"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image6:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"72";
    labelVC.label = sender.userInfo[@"马场婚纱"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image7:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"58";
    labelVC.label = sender.userInfo[@"马尔代夫"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image8:(NSNotification *)sender{
    LabelViewController *labelVC = [[LabelViewController alloc]init];
    labelVC.mark = @"60";
    labelVC.label = sender.userInfo[@"巴厘岛"];
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(void)image9:(NSNotification *)sender{
    AllLabelViewController *labelVC = [[AllLabelViewController alloc]init];
   
    [self.navigationController pushViewController:labelVC animated:YES];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        FuwuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FuwuTableViewCell"];
        return cell;
        
    }
    if (indexPath.section == 1) {
        PhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PhotoTableViewCell"];
        return cell;
    }
    if (indexPath.section == 2) {
        CaigouTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CaigouTableViewCell"];
        return cell;
    }
    if (indexPath.section == 3) {
        ReimenTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReimenTableViewCell"];
        return cell;
    }
    
    return nil;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 350;
    }
    if (indexPath.section == 1) {
        return 100;
    }
    if (indexPath.section == 2) {
        return 250;
    }
    if (indexPath.section == 3) {
        return 200;
    }
    
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 20;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark  --- 移除所有通知的监听
-(void)dealloc{
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    //移除所有通知的监听
    [center removeObserver:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
